#include<bits/stdc++.h>
#include<iostream>
#include<unordered_map>
#include<vector>
using namespace std;
//设个表
unordered_map<string,int>day_to_num={
	 {"monday", 0},
    {"tuesday", 1},
    {"wednesday", 2},
    {"thursday", 3},
    {"friday", 4},
    {"saturday", 5},
    {"sunday", 6}
};
  
int main(){
	int T;
	cin>>T;
	cin.ignore(); 
	for(int test_case=0;test_case<T;++test_case){
		string S,E;
		int L,R;
		cin>>S>>E>>L>>R;
		//获取起始和结束的星期编号
		int start=day_to_num[S];
		int end=day_to_num[S];
		
		//计算需要的满足的模7余数
		int target=(end-start+7)%7;
		vector<int>valid_days;
		
		//遍历[L, R]区间中的每一天
		for(int D=L;D<=R;++D){
			//符合就进去
			if((D-1)%7==target){
				valid_days.push_back(D);
			}
		}
		//判断结果
		if(valid_days.empty()){
			 cout << "impossible" << endl;
		}
		else if (valid_days.size() > 1) {
            cout << "many" << endl;
        } else {
            cout << valid_days[0] << endl;
        }
	}
	
}